package ${cfg.package_name}.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
  * @author ${author}
  * @since ${date}
 */
public enum ${cfg.enumsMap.className} {
    <#list cfg.enumsMap.columnOptionDataDtoList as optionDataDto>
    ${optionDataDto.optionName}(${optionDataDto.keyName}, "${optionDataDto.valueName}")<#if (optionDataDto_has_next)>,<#else>;</#if>
    </#list>

    private final Integer id;
    private final String name;

    ${cfg.enumsMap.className}(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public static String explain(Integer id) {
        return explain(id, null) ;
    }

    public static String explain(Integer id, String unexpectedValue) {
        for (${cfg.enumsMap.className} enum1 : ${cfg.enumsMap.className}.values()) {
            if (enum1.id.equals(id)) {
                return enum1.getName();
            }
        }
        return unexpectedValue;
    }

    public static List<Map<String,Object>> toList () {
        List <Map<String,Object>> list = new ArrayList();
        for (${cfg.enumsMap.className} enum1 : ${cfg.enumsMap.className}.values()) {
            Map<String,Object> map = new HashMap();
            map.put("id", enum1.getId());
            map.put("name", enum1.getName());
            list.add(map);
        }
        return list;
    }

    public Integer getId() {
        return id;
    }

    public String getName() {
        return name;
    }

}
